﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace EpisodeWizard.CoreUI
{

	public partial class WizardPage : UserControl
	{
		/// <summary>
		/// The title of the page
		/// </summary>
		[
			BrowsableAttribute(true),
			CategoryAttribute("Wizard page"),
			DescriptionAttribute("Page title"),
			DefaultValueAttribute("New page"),
		]
		public string PageTitle
		{
			get;
			set;
		}

		/// <summary>
		/// The icon of the page
		/// </summary>
		[
			BrowsableAttribute(true),
			CategoryAttribute("Wizard page"),
			DescriptionAttribute("Page icon"),
		]
		public Image PageIcon
		{
			get;
			set;
		}


		/// <summary>
		/// Suscribe if you want to do something when the page is shown
		/// </summary>
		public event NotifyHandler EnterPage;
		public delegate void NotifyHandler();

		/// <summary>
		/// Suscribe if you want to do something when the page is closed
		/// </summary>
		public event NotifyHandler LeavePage;

		/// <summary>
		/// When suscribing to the Validate event, set Cancel to false to prevent from going to the next page
		/// </summary>
		public class ValidatePageEventArgs
		{
			public bool Cancel;
		}

		/// <summary>
		/// Suscribe to validate/invalidate the data on the your page
		/// You can cancel the page change by setting the Cancel parameter to true
		/// </summary>
		public event ValidatePageHandler ValidatePage;
		public delegate void ValidatePageHandler(ValidatePageEventArgs e);

		public void OnEnterPage()
		{
			if (EnterPage != null)
			{
				EnterPage();
			}
		}

		public void OnLeavePage()
		{
			if (LeavePage != null)
			{
				LeavePage();
			}
		}

		public void OnValidatePage(ValidatePageEventArgs e)
		{
			if (ValidatePage != null)
			{
				ValidatePage(e);
			}
		}

		/// <summary>
		/// A wizard page
		/// </summary>
		public WizardPage()
		{
			InitializeComponent();
		}

	}
}
